#pragma once
#pragma once

#include"RBtree.h"

namespace gm
{
	template<class K>
	class set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename RBtree<K, K, SetKeyOfT>::const_iterator iterator;
		typedef typename RBtree<K, K, SetKeyOfT>::const_iterator const_iterator;



		iterator begin() const
		{
			return _t.begin();
		}

		iterator end() const
		{
			return _t.end();
		}
		pair<iterator, bool> insert(const K& key)
		{
			pair<typename RBtree<K, K, SetKeyOfT>::iterator, bool> ret = _t.insert(key);
			return pair<iterator, bool>(ret.first, ret.second);
		}
	private:
		RBtree<K, K, SetKeyOfT> _t;
	};

	void test_set()
	{
		set<int> s;
		int arr[] = { 4,2,6,1,3,5,15,7,16,14 };
		for (auto e : arr)
		{
			s.insert(e);
		}

		set<int>::iterator it = s.begin();
		while (it != s.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;
	}
}